package org.karelun.gef.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.karelun.gef.helper.ConstantMessages;
import org.karelun.gef.helper.IDConstant;

public class CloseAction extends Action{
	private IWorkbenchWindow window;
	
	public CloseAction(IWorkbenchWindow window){
		this.window=window;
		setId(IDConstant.closeEditorAction_Id);
		setText(ConstantMessages.close_Text);
		setActionDefinitionId(IDConstant.closeEditorAction_CMD_ID);
	}
	
	public void run(){
		IWorkbenchPage page = window.getActivePage();
		IEditorPart editor = page.getActiveEditor();
		page.closeEditor(editor, true);
	}
}
